<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//Dtd HTML 4.01 transitional//EN" "http://www.w3.org/tr/html4/loose.dtd">
<%@taglib uri="/struts-tags" prefix="s"%>

<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title><s:text name="welcome"/>: Main</title>
		<s:head />
		
	</head>
	
	<body>
		<s:include value="header.jsp"/>
		<s:if test="allGames != null && allGames.size() > 0">
			<table border="1" cellpadding="4" cellspacing="5">
				<tr>
					<td><strong>Edit</strong></td>
					<td><strong>Delete</strong></td>
					<td><strong>Id</strong></td>
					<td><strong>Nombre</strong></td>
					<td><strong>Descripción</strong></td>
					<td><strong>Género</strong></td>
					<td><strong>Valoración</strong></td>
				</tr>
				<s:iterator value="allGames" status="gameList">
				<tr>
					<td><s:url id="editURL" action="edit">
							<s:param name="id" value="id" />
						</s:url> 
						<s:a href="%{editURL}">Edit</s:a>
					</td> 
					
					<td><s:url id="deleteURL" action="delete">
							<s:param name="id" value="id" />
						</s:url> 
						<s:a href="%{deleteURL}">Delete</s:a>
					</td> 
					
					<td><s:property value="id" /></td> 
					<td><s:property value="name" /></td> 
					<td><s:property value="description" /></td> 
					<td><s:property value="kind" /></td>
					<td><s:property value="userValue" /></td>
				</tr>
				</s:iterator>
			</table>
		<s:else>
			<p>No hay juegos disponibles</p>
		</s:else>
		</s:if>
		<br />
		
		<s:set var="shooter" value="getText('shooter')"/>
		<s:set var="arcade" value="getText('arcade')"/>
		<s:set var="rpg" value="getText('rpg')"/>
		<s:set var="adventure" value="getText('adventure')"/>
		
		<s:form action="saveOrUpdate">
			<s:push value="game" >
				<s:hidden name="id"/>
				<s:textfield key="name"/>
				<s:textfield key="description"/>
				<s:select key="kind" list="#{'0':#shooter,'1':#arcade,'2':#rpg,'3':#adventure}" />
		   		<s:select key="userValue" list="#{'0':'1','1':'2','2':'3','3':'4','4':'5','5':'6','6':'7','7':'8','8':'9','9':'10'}" />
	   			<s:submit key="update_insert"/>
	   		</s:push>
		</s:form>
	</body>
</html>